﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.ComponentModel;
using NovinMedia.Data;

namespace NovinMedia.Data.Layer
{
    [DataObject(true)]
    public class NhanVien
    {
		[DataObjectMethod(DataObjectMethodType.Fill)]
		public DataSet SelectAll()
        {
            DbObject dbo = new DbObject();
            SqlParameter[] parameters = new SqlParameter[]
                {
 
                };
            return dbo.RunProcedure("pr_NhanVien_SelectAll", parameters, "NhanVien");
        }

		[DataObjectMethod(DataObjectMethodType.Fill)]
		public DataSet SelectRow(string MaNV)
        {
            DbObject dbo = new DbObject();
            SqlParameter[] parameters = new SqlParameter[]
                {
					new SqlParameter("MaNV",MaNV) 
                };
            return dbo.RunProcedure("pr_NhanVien_SelectRow", parameters, "NhanVien");
        }

		[DataObjectMethod(DataObjectMethodType.Insert)]
		public int InsertRow(string MaNV,string TenNV,string GioiTinh,DateTime NgaySinh,string SoCMND,DateTime NgayVaoLam,string ChucVu,string DiaChi,string SDT,string TenDangNhap,string MatKhau)
		{
			int RowsAffected = 0;
			int Result = 0;
			DbObject dbo = new DbObject();
			SqlParameter[] parameters = new SqlParameter[]
				{
					new SqlParameter("MaNV",MaNV),
					new SqlParameter("TenNV",TenNV),
					new SqlParameter("GioiTinh",GioiTinh),
					new SqlParameter("NgaySinh",NgaySinh),
					new SqlParameter("SoCMND",SoCMND),
					new SqlParameter("NgayVaoLam",NgayVaoLam),
					new SqlParameter("ChucVu",ChucVu),
					new SqlParameter("DiaChi",DiaChi),
					new SqlParameter("SDT",SDT),
					new SqlParameter("TenDangNhap",TenDangNhap),
					new SqlParameter("MatKhau",MatKhau) 
				};
			Result = dbo.RunProcedure("pr_NhanVien_Insert", parameters, out RowsAffected);
			return Result;
        }

		[DataObjectMethod(DataObjectMethodType.Update)]
		public int UpdateRow(string MaNV,string TenNV,string GioiTinh,DateTime NgaySinh,string SoCMND,DateTime NgayVaoLam,string ChucVu,string DiaChi,string SDT,string TenDangNhap,string MatKhau)
		{
			int RowsAffected = 0;
			int Result = 0;
			DbObject dbo = new DbObject();
			SqlParameter[] parameters = new SqlParameter[]
				{
					new SqlParameter("MaNV",MaNV),
					new SqlParameter("TenNV",TenNV),
					new SqlParameter("GioiTinh",GioiTinh),
					new SqlParameter("NgaySinh",NgaySinh),
					new SqlParameter("SoCMND",SoCMND),
					new SqlParameter("NgayVaoLam",NgayVaoLam),
					new SqlParameter("ChucVu",ChucVu),
					new SqlParameter("DiaChi",DiaChi),
					new SqlParameter("SDT",SDT),
					new SqlParameter("TenDangNhap",TenDangNhap),
					new SqlParameter("MatKhau",MatKhau) 
				};
			Result = dbo.RunProcedure("pr_NhanVien_Update", parameters, out RowsAffected);
			return Result;
        }

		[DataObjectMethod(DataObjectMethodType.Delete)]
		public int DeleteRow(string MaNV)
		{
			int RowsAffected = 0;
			int Result = 0;
			DbObject dbo = new DbObject();
			SqlParameter[] parameters = new SqlParameter[]
				{
					new SqlParameter("MaNV",MaNV) 
				};
			Result = dbo.RunProcedure("pr_NhanVien_DeleteRow", parameters, out RowsAffected);
			return Result;
        }
    }
}